<template>
  <div class="dashboard-wide">
    <div class="card-list bg-two" v-for="(session, index) in sessionData" :key="index">
      <div class="card-body">
        <div class="card-body-items-center">
          <div class="db-icon">
            <a-icon type="diff"/>
          </div>
          <div class="db-info">
            <h3>{{ session.value }}</h3>
            <h6>{{ session.name }}</h6>
          </div>
        </div>
      </div>
    </div>
  </div>
  
</template>

<script>
// import { getMcaCount } from '@/api/performance'
import moment from 'moment'
export default {
  name: 'SessionCount',
  components: {
  },
  data () {
    return {
      sessionData: [
        {
          name: '活跃Session数',
          value: 830
        }, {
          name: '无效Session数',
          value: 8300
        }, {
          name: '提交数',
          value: 83
        }, {
          name: '回滚数',
          value: 12
        }, {
          name: '活跃解析总数',
          value: 3450
        }
      ]
    }
  },
  created () {
  },
  mounted () {
    // 轮询接口
    const timers = window.setInterval(() => {
      setTimeout(res => {
      }, 0)// 利用定时器清除setInterval的每次叠加
    }, 60000)// 1分钟执行一次
    // this.once在离开当前路由时销毁定时器
    this.$once('hook:beforeDestroy', () => {
      clearInterval(timers)
    })
  },
  /**
   * 数字格式化为千分位
   */
  filters: {
    format: function (value) {
      return value.toLocaleString()
    }
  },
  methods: {
  }
}
</script>
<style lang="less" scoped>
  .dashboard-wide {
    display: -webkit-flex; /* Safari */
    display: flex;
    justify-content:space-between;
    .card-list {
      width: 19%;
      border: 1px solid #ececf5;
      box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.03);
      margin-bottom: 1.2rem;
      .card-body {
        padding: 0.8rem 1rem;
        .card-body-items-center{
          display: -webkit-flex; /* Safari */
          display: flex;
          justify-content:space-between;
          align-items:center;
          .db-icon {
            font-size: 25px;
            width: 45px;
            height: 45px;
            padding: 5px 10px;
            border-radius: 10px;
            color: #fff;
          }
          .db-info{
            h3{
              font-size: 20px;
              margin-bottom: 0;
              text-align: right;
            }
            h6{
              color: #666;
              font-size: 0.8rem;
              overflow:hidden;
              text-overflow:ellipsis;
              white-space: nowrap;//文本不进行换行，默认下宽度不够就会换行。
            }
          }
        }
      }
    }
    .bg-two {
      background-color: rgba(255, 255, 255, 0.9);
      border-color: #19affb;
      border-radius: 30px 0px;
      .db-icon {
        background-color: #19affb;
        padding: 5px 10px;
      }
    }
  }
</style>
